package org.example.model;

public class Test {

    public static void main(String[] args) {
//        String us = "LDClientMac_7.12.2.2_MacOSX_10.16";
//        Boolean res = Test.greaterMacVersion(us,"7.6");
//        System.out.println(res);
//        ==basePara.getPath()=/test摆渡1/11/11/1.docx,parentPath=/11/
        String basePara = "/test摆渡1/11/11/1.docx";
        String parentPath = "/11/";
        int firstIndex = basePara.indexOf(parentPath);
        System.out.println(firstIndex);


        String res = basePara.substring(firstIndex + 1);
        System.out.println(res);


    }



    public static Boolean greaterMacVersion(String ua,String targetVersion){
        try{
            int offset = "LDClientMac_".length();
            int endIndex = ua.indexOf("_MacOSX",offset);
            String version = ua.substring(offset,endIndex);
//       7.6  7.6  <= 7.6
            String[] versionArray = version.split("\\.");
            String[] targetVerArr = targetVersion.split("\\.");

            String[] newVersionArry = new String[2];

            for (int i = 0; i < 2; i++) {
                newVersionArry[i] = versionArray[i];
            }

            //对分隔的每个逗号的版本进行比较  7.12.2.3 是大于 7.6的
            for (int i = 0; i < newVersionArry.length; i++) {
                Integer curVersion = Integer.valueOf(newVersionArry[i]);
                Integer targetVer = 0;
                if(i < targetVerArr.length){
                    targetVer = Integer.valueOf(targetVerArr[i]);
                }
                if(curVersion > targetVer){
                    return true;
                }else if(curVersion < targetVer){
                    return false;
                }
            }
        }catch (Exception e){
           e.printStackTrace();
        }
        return false;
    }
}
